if условие then действие


Описание:

Структура условного перехода. Когда удволетворяется условие (не равно null, 0,0.0,"") - выполняется действие. Если усовие не удволетворяется (else) выполняется альтернативное действие.

Пример:

local a=rand(0, 1), b=rand(0, 1), c=rand(0, 1)
local d=rand(0, 30)

if a==true then print("first condition is true!")

if b==true
    print("second condition is true!")
end

if c
    print("third condition is true!")
else
    print("third condition is false!")
end

if c<10
    print("fourth condition value is less than 10!")
else if c<20
    print("fourth condition value is greater than 10 but less than 20!")
else
    print("fourth condition value is greater than 20!")
end